package util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;

import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;

import com.example.android.sip.WalkieTalkieActivity;

public class AccountFileUtil {

	public Properties readFromFS(WalkieTalkieActivity caller) {
		try{
			Properties fileProps = new Properties();
			File dir = caller.getApplicationContext().getFilesDir();
			File input = new File(dir.getAbsolutePath() + "/preferences" );
			fileProps.load(new FileInputStream(input));
			return fileProps;
		}
		catch(Exception e){}
		return null;
	}
	
	public void writeFromFS(WalkieTalkieActivity caller){
		try{
			Properties props = new Properties();
			props.put("clau","stronzo");
			File dir = caller.getApplicationContext().getFilesDir();
			File out = new File(dir.getPath() + "/preferences") ;
			props.put("location" , dir.getAbsolutePath());
			props.save(new FileOutputStream(out), null);
		}
		catch(Exception e){}
	}
	public ListView browseAccount(WalkieTalkieActivity caller){
		ListView map = new ListView(null);
		try{
			File dir = caller.getApplicationContext().getFilesDir();
			int i = 0;
			Properties props  = new Properties();
			while ( true) {
				props.load(new FileInputStream(dir.getAbsolutePath() + "/preferences" + i));
				String account = (String)props.get("account");
				//map.setite
				i++;
			}
			
		}
		catch(Exception e){}
		return map;
	}
}
